//
//  AddressItemFrame.m
//  JiaoX
//
//  Created by yinqy on 15/1/16.
//  Copyright (c) 2015年 北京娇羞科技有限公司. All rights reserved.
//

#import "AddressItemFrame.h"
#import "LocationDao.h"

#define EDITBTN_WIDTH [DimensUtils getScaleX:66]
#define EDITBTN_HEIGHT [DimensUtils getScaleX:27]

@implementation AddressItemFrame


-(void)setDetail:(AddressDetail *)detail{
    _detail = detail;
    
    self.adresSelectBtnFrame = CGRectMake(JXScreenW-SELECT_IMG_HEIGHT-JXPublicInset, JXPublicInset*1.5, SELECT_IMG_HEIGHT, SELECT_IMG_HEIGHT);
    
    CGSize size = [detail.addressee sizeWithFont:[UIFont systemFontOfSize:NAME_FONT_SIZE]];
    self.adresNameFrame = CGRectMake(JXPublicInset, JXPublicInset*1.5, JXScreenW-JXPublicInset*3-SELECT_IMG_HEIGHT, size.height);
    
    self.adresPhoneFrame = CGRectMake(JXPublicInset, CGRectGetMaxY(self.adresNameFrame)+JXPublicInset, self.adresNameFrame.size.width, NAME_FONT_SIZE);
    LocationDao *dao = [[LocationDao alloc]init];
    NSString *detailAddressPre = [dao getDetaild:detail.provinceId :detail.cityId :detail.areaId :@"-"];
    NSString *detailAddress = [NSString stringWithFormat:@"%@-%@",detailAddressPre,detail.detailAdres];
    [detail setDetailAdres2:detailAddress];
    CGSize detailSize = [detailAddress sizeWithFont:[UIFont systemFontOfSize:NAME_FONT_SIZE] constrainedToSize:CGSizeMake(JXScreenW-JXPublicInset*2, MAXFLOAT)];
    self.adresDetailFrame = CGRectMake(JXPublicInset, CGRectGetMaxY(self.adresPhoneFrame)+JXPublicInset, detailSize.width, detailSize.height);
    
    self.adresEditBtnFrame = CGRectMake(JXPublicInset,  CGRectGetMaxY(self.adresDetailFrame)+JXPublicInset*1.5, EDITBTN_WIDTH, EDITBTN_HEIGHT);

    self.adresDeleteBtnFrame = CGRectMake(JXScreenW-JXPublicInset-EDITBTN_WIDTH, self.adresEditBtnFrame.origin.y, EDITBTN_WIDTH, EDITBTN_HEIGHT);
    
    self.selfFrame = CGRectMake(0, 0, JXScreenW, CGRectGetMaxY(self.adresDeleteBtnFrame)+JXPublicInset*1.5);
}
@end
